This invention relates to methods and systems for hinting fonts, particularly TrueType fonts.
The demand for high-quality hinted fonts is outstripping the ability of digital typography houses to produce them. Hinting is a painstaking manual process that can only be done well by a handful of highly skilled professionals. It requires a blend of typographical artistry with technological ability. In order to provide a full appreciation of the hinting problem, a review of how digital fonts are scan-converted onto a raster display is given.
In digital typography, each character in a font is described by a set of outlines, usually represented by splines. When the character is rendered onto a grid of pixels, the outlines are scaled to the desired size, and then each pixel whose center lies inside of an outline is set to black. When fonts are displayed at sufficiently high resolutions, this approach works beautifully. But for sizes below about 150 ppem, severe aliasing problems can result when this naive outline filling process is applied, especially for delicate features such as serifs. As an aside, hinters express font sizes in pixels per em, or ppem. This measure counts the number of device pixels in the em of the font. In traditional typography, the em of a font was the height of the metal block of type. With digital typography, there is no actual metal block to measure, but the digital outlines are still expressed in coordinates relative to this hypothetical size. The point size of text refers to the size of its em expressed in points (a point is {fraction (1/72)} of an inch). Thus, xe2x80x9c12-point textxe2x80x9d would correspond to 12 ppem on a 72 dpi screen, or 100 ppem on a 600 dpi printer.
FIG. 1 shows an example of the aliasing problems that can result when a naive outline filling process is applied. Consider the leftmost image 100 in the form of a lower case letter xe2x80x9caxe2x80x9d which represents an outline of the character that is to be filled. The centermost image 102 (absent the illustrated black pixels 102a) is generated by a naive algorithm. This pixel pattern does not look much like a lowercase xe2x80x9caxe2x80x9d. A simple dropout control mechanism can be added to the fill algorithm to turn on additional pixels to preserve the character""s topology. The resultant pixels that are turned on by the dropout control mechanism are shown in black at 102a. The rightmost image 104 illustrates the work of an experienced hinter. It will be observed that the pixel pattern has been subtly altered to both improve readability and better preserve the character of the original outline.
The hinting process is not just about optimizing individual characters. The hinter must balance the needs of a single glyph with the desire for consistency across all the characters of a font. It is important, for example, to ensure that all the vertical stems of a font are the same number of pixels wide at a given size. If the scaling and rounding process produces one-pixel-wide stems on some characters and two-pixel-wide stems on others, then a passage of text will look blotchy and be difficult to read. The goal of the hinter is to produce a smooth transition from very high sizes, where merely filling the outlines suffices and hinting is unnecessary, down to lower sizes, where legibility must be preserved even when that means a departure from the outlines drawn by the original font designer.
Although the ever-improving resolution of hardcopy devices is beginning to approach the point at which hinting is not necessary, the technology is not there yet: 10- or 12-point text on a 300 or even 600 dpi printer still needs hinting for best results. More importantly, the increasing emphasis on reading text on-screenxe2x80x94from visions of the xe2x80x9cpaperless officexe2x80x9d to the emergence and proliferation of hand-held computers and eBooksxe2x80x94means that more and more text is being viewed on devices in the 72-100 dpi range. Though resolutions of these displays are improving as well, for the foreseeable further hinting will be an absolute necessity in order to provide clear, legible text.
Although attempts have been made to design automated hinting systems in the past, even the best of these produce hints that are good, but still not up to the standards of professional typographers. Exemplary systems are described in the following references: Andler, Automatic generation of gridfitting hints for rasterization of outline fonts or graphics, Proceedings of the International Conference on Electronic Publishing, Document Manipulation, and Typography, pps. 221-234, September 1990, and Hersch, Character generation under grid constraints, Proceedings of SIGGRAPH 87, pps. 243-252, July 1987.
This previous work assumed that in order to be useful, an autohinter had to be a monolithic, self-contained package: outlines in, quality hints out. That is an admirable goal, and it may be achieved someday. However, given the detailed, aesthetically-based nature of the work, a better, more useful approach is to view the autohinter as one piece of a system that includes a human hinter.
There are two major font standards in widespread use today: Type 1 and TrueType. Type 1 fonts (Adobe Systems Inc., Adobe Type 1 Font Format, March 1990), often called xe2x80x9cPostScript fonts,xe2x80x9d were developed by Adobe and are popular in the world of publishing. Printing applications were the target when this system was developed, though utilities are now available to enable on-screen display of Type 1 fonts. The TrueType format (Apple Computer, Inc., The TrueType Font Format Specification, 1990, Version 1.0), originally developed by Apple, was intended to unify type on the screen and on paper, and is used in both the Macintosh and Windows operating systems. TrueType has something of a reputation for being of low quality, but this is mostly due to the fact that TrueType was always an open standard while Type 1 was not, and so the public domain is flooded with a large number of poorly designed, unhinted TrueType fonts. The TrueType standard does contain extensive facilities for high-quality hinting, though, and through the efforts of Monotype and other typography houses, more and more quality fonts are now available in the TrueType format.
Though both formats represent characters as spline-based outlines, the hinting styles are radically different. Hinting for Type 1 fonts works by marking sections of the outline as corresponding to particular typographic features of the characterxe2x80x94stems, bowls, counters, and so on. It is the job of the rasterizer to take advantage of these hints about the character shape to produce the best possible pattern of pixels. This scheme has the advantage that enhancements to the rasterizer can produce improvements to all fonts on the system, but means that a designer of digital type cannot specify exactly what an outline will look like when rendered at a given size.
The TrueType font technology takes a different approach. Instead of leaving control over the glyph""s final appearance to the rasterizer, a TrueType font contains explicit instructions (hints) about how particular control points should be shifted to fit the pixel grid. These instructions take the form of a program in a special, TrueType-specific bytecode language. Since both the behavior of each instruction and the rasterizing algorithm are defined in the TrueType standard, the designer of a TrueType font can predict exactly which pixels will be turned on for a character at a given size, no matter what type of output device is being used.
In TrueType, each contour of an outline is specified with a sequence of point positions (also referred to herein as xe2x80x9ccontrol pointsxe2x80x9d or xe2x80x9cknotsxe2x80x9d). FIG. 2 shows exemplary outline curves of the lowercase letter xe2x80x9caxe2x80x9d for two fonts: Trebuchet and Frutiger. Each point is flagged as either xe2x80x9con-curvexe2x80x9d or xe2x80x9coff-curvexe2x80x9d. TrueType defines the outline as follows:
Two successive on-curve points are connected with a straight line segment.
When an off-curve point falls between two on-curve points, the three are treated as the control points for a quadratic Bxc3xa9zier segment.
When two adjacent off-curve points appear, the midpoint of the segment connecting them is treated as an implicit on-curve point between them, allowing reduction to the case above.
The glyph renderer starts by scaling the outlines to a particular size, then executes the attached program to shift control points around in a size-specific way before filling the altered outline. By itself, this approach cannot produce the necessary consistency among different characters of a font, or even between different parts of the same character, since each action is necessarily local. Global synchronization of outline alterations is achieved through use of a control value table, or CVT. The CVT is a shared table of distances, that can be referenced by instructions in each glyph""s program. When the rendering is initialized for a given size, the values in the CVT are scaled and rounded to the current grid size. Point movements can then be constrained by CVT entries. For instance, a person writing hints for TrueType may decide to use CVT 81 to represent, say, the width of vertical black stems in lowercase letters. He or she will then write instruction sequences for all appropriate lowercase letters, all referring to CVT entry 81, so that all the vertical black stems at a given size will have the same width.
The TrueType language is an assembly-style stack-based language. The intent of the designers of TrueType was not to make typographers learn and write in the TrueType language itself, but rather to facilitate the development of high-level languages and tools that generate TrueType code. The Visual TrueType (VTT) package from Microsoft is such a tool. VTT is described in detail in Stamm, A Graphical Method for Authoring Font Intelligence, Electronic Publishing, Raster Imaging, and Digital Typography, pps. 77-92, March/April 1998.
VTT provides a high-level language, called xe2x80x9cVTT Talkxe2x80x9d, for expressing relationships between points. VTT Talk provides statements for expressing the following classes of hints:
Link constraints: the vertical or horizontal distance between a pair of knots is constrained by an entry in the CVT.
Dist constraints: the xe2x80x9cnaturalxe2x80x9d vertical or horizontal distance between a pair of knots is maintained, so that if one point is moved the other moves in parallel.
Interpolate constraints: a knot""s fractional distance between two parent knots is maintained.
Anchors: specific knots can be rounded to the nearest gridline, or to a gridline specified by a CVT entry.
These types of hints are demonstrated visually for two characters from the Georgia Roman font in FIG. 3. There, the constraints are labeled for identification.
The VTT Talk hints are compiled into a TrueType program stored in the font file. One advantage of working with VTT Talk is that each statement simply asserts a relationship between two points, and there is little dependence on the order of the statements. If one statement is omitted, the meaning of the others is unchanged. In contrast, TrueType assembler is a sequential language that maintains a fairly complex state. Most instructions in TrueType have side effects that modify this state. If one tried to translate the assembler code directly, and were for some reason unable to translate a particular instructionxe2x80x94for instance, due to a sufficiently large difference in the matched glyphs"" outlinesxe2x80x94the effects of subsequent instructions could change entirely.
This invention arose out of concerns associated with improving the systems and methods through which hinting takes place. In particular, the invention arose out of concerns associated with improving TrueType hinting systems and tools.
Methods and systems for hinting fonts, particularly TrueType fonts, are described. The inventive methods and systems provide a mechanism by which hints are automatically translated from one font to another. An advantageous feature of the described approach is that it preserves the basic strategy and structure of the original hints, which were handcrafted by a professional typographer for each individual glyph of the font. Generally, these translated hints provide an excellent starting point for a human typographer to fine-tune and adjust.
In the illustrated and described embodiment, a character or glyph (i.e. a source character) from a first font is selected and provides hints that are to be transferred to a character or glyph of a second font (i.e. a target character). The hints, in the described embodiment, are TrueType hints that are statements defined in terms of control points or knots that define the shape or appearance of a character. The hints constrain the character""s control points, e.g. the distance between a pair of control points or how the points relate to one another. Outlines or contours for the two characters are first matched to establish a correspondence between the characters. Next, various attempts are made to find a xe2x80x9cbest matchxe2x80x9d between individual control points on the source character and target character.
In the illustrated and described embodiment, finding a best match between individual control points on the different characters involves a process by which control points on the source character are paired with different control points on the target character. Each pairing of control points is then scored in accordance with predefined criteria to provide a local feature score for each control point pair. The local feature score is a measure of how well the individual control points match. The local feature scores are then summed to provide an overall score of the set of paired control points. Different control point pairings are tried and result in multiple sets of paired control points. Each of the sets of paired control points has an overall score.
A predetermined number of the best overall scores are selected and then each overall score is attempted to be improved upon. This takes place by manipulating the individual control point pairings within each set that corresponds to an overall score, subject to a condition designed to preserve the order of the control points. The result of this process is a single score that reflects the best or most optimal pairing of control points.
Once a desirable pairing of control points is ascertained, hints from the source character can be translated to the target character. Advantageously, in the described embodiment, translation of the hints involves manipulating control point references in the defined hints so that the hints now refer to control points in the target character rather than control points in the source character. Because the most optimal pairing of control points was ascertained, this process is greatly facilitated.
In addition, the hints can contain references to a control value table (CVT). The CVT contains table entries that are associated with values that are used to constrain the control points of the source character. In accordance with one embodiment, CVT values are manipulated so that the entries now correspond to values that are used to constrain the character in the target font. Manipulating the CVT values recognizes that there are differences between the source and target characters and that using the values associated with the source character in connection with the target character would be inappropriate.